﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MyManageViewControl
{
    public partial class ManageView: UserControl
    {
        public event EventHandler TextChanged;

        public event EventHandler Click;

        public event EventHandler Add;

        public event EventHandler Delete;

        public event EventHandler Update;

        public string SearchKey
        {
            get { return tbxKey.Text; }
            set { tbxKey.Text = value; }
        }

        public object DataSource
        {
            get { return lbxResult.DataSource; }
            set { lbxResult.DataSource = value; }
        }

        public object SelectedItem
        {
            get { return lbxResult.SelectedItem; }
            set { lbxResult.SelectedItem = value; }
        }

        public int SelectedIndex
        {
            get { return lbxResult.SelectedIndex; }
            set { lbxResult.SelectedIndex = value; }
        }

        public string DisplayMember
        {
            get { return lbxResult.DisplayMember; }
            set { lbxResult.DisplayMember = value; }
        }

        public ManageView()
        {
            InitializeComponent();
           
        }

        private void tbxKey_TextChanged(object sender, EventArgs e)
        {
            if (TextChanged != null)
            {
                TextChanged(sender, e);
            }
        }

        private void lbxResult_Click(object sender, EventArgs e)
        {
            if (Click != null)
            {
                Click(sender, e);
            }
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (Add != null)
            {
                Add(sender, e);
            }
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (Delete != null)
            {
                Delete(sender, e);
            }
        }

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (Update != null)
            {
                Update(sender, e);
            }
        }

        private void ManageView_Load(object sender, EventArgs e)
        {

        }
    }
} 
